package o;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;
import com.huawei.appgallery.push.api.receiver.PushDealReceiver;
import com.huawei.appmarket.service.installdepend.bean.GetDetailByIdResBean;
import com.huawei.appmarket.service.installdepend.bean.GetDetailByIdResBean$DetailInfoBean;
import com.huawei.appmarket.service.reserve.game.bean.ReserveResponse;
import com.huawei.appmarket.service.thirdappdl.ThirdAppDownloadActivityProtocol;
import com.huawei.appmarket.service.thirdappdl.ThirdAppDownloadActivityProtocol.Request;
import com.huawei.hms.framework.network.restclient.hianalytics.HianalyticsData;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.io.Serializable;
import org.json.JSONException;
import org.json.JSONObject;

public class eeo extends AsyncTask<String, Void, cuk> {
    private Bitmap ˊ = null;
    private Bitmap ˋ = null;
    private final Context ˎ;
    private JSONObject ॱ;

    static class b {
        public static cuk ˏ(JSONObject jSONObject, int i) throws JSONException {
            cuk o_cuk = new cuk();
            o_cuk.ˋ(i);
            String string = jSONObject.getString("cmd");
            o_cuk.ᐝॱ(string);
            Logger.ˎ("PushNotificationTask", "PushNotificationTask creatBeanByMsg type=" + string);
            ˏ(jSONObject, o_cuk);
            ˎ(jSONObject, o_cuk);
            ˋ(jSONObject, o_cuk);
            ˊ(jSONObject, o_cuk);
            ॱॱ(jSONObject, o_cuk);
            ॱ(jSONObject, o_cuk);
            if ("feedBack".equals(string)) {
                o_cuk.ʻॱ(HwAccountConstants.TYPE_SECURITY_PHONE);
            } else {
                JSONObject jSONObject2 = jSONObject.getJSONObject("param");
                if (HianalyticsData.EXCEPTION_MESSAGE.equals(string)) {
                    ॱ(o_cuk, jSONObject2);
                } else if ("app".equals(string)) {
                    ˋ(o_cuk, jSONObject2);
                } else if ("web".equals(string)) {
                    ˏ(o_cuk, jSONObject2);
                } else if ("hispace".equals(string)) {
                    ˊ(o_cuk, jSONObject2);
                } else if ("webview".equals(string)) {
                    ˎ(o_cuk, jSONObject2);
                } else if ("bindPhone".equals(string)) {
                    ʻ(o_cuk, jSONObject2);
                } else if ("commentReply".equals(string)) {
                    ᐝ(o_cuk, jSONObject2);
                } else if ("selfDef".equals(string)) {
                    ʼ(o_cuk, jSONObject2);
                } else if ("addWishInfo".equals(string) || "addGameReserveInfo".equals(string)) {
                    eeo.ॱ(o_cuk, jSONObject2);
                }
            }
            Logger.ˎ("PushNotificationTask", "PushNotificationTask getJsonToInsert *" + string + "* pushMsgBean.type=" + o_cuk.ॱˎ());
            return o_cuk;
        }

        private static void ॱ(JSONObject jSONObject, cuk o_cuk) throws JSONException {
            if (jSONObject.has("v")) {
                o_cuk.ˊ(dof.ʼ(jSONObject.getString("v")));
            }
        }

        private static void ˏ(JSONObject jSONObject, cuk o_cuk) throws JSONException {
            if (jSONObject.has("title")) {
                o_cuk.ॱ(dof.ʼ(jSONObject.getString("title")));
            }
        }

        private static void ˎ(JSONObject jSONObject, cuk o_cuk) throws JSONException {
            if (jSONObject.has("content")) {
                o_cuk.ʽ(dof.ʼ(jSONObject.getString("content")));
            }
        }

        private static void ˋ(JSONObject jSONObject, cuk o_cuk) throws JSONException {
            if (jSONObject.has("sessionID")) {
                o_cuk.ʼ(dof.ʼ(jSONObject.getString("sessionID")));
            }
        }

        private static void ˊ(JSONObject jSONObject, cuk o_cuk) throws JSONException {
            if (jSONObject.has("icon")) {
                o_cuk.ॱᐝ(dof.ʼ(jSONObject.getString("icon")));
            }
        }

        private static void ॱॱ(JSONObject jSONObject, cuk o_cuk) throws JSONException {
            if (jSONObject.has("watchIcon")) {
                o_cuk.ʿ(jSONObject.getString("watchIcon"));
            }
        }

        private static void ॱ(cuk o_cuk, JSONObject jSONObject) throws JSONException {
            o_cuk.ʻॱ("2");
            o_cuk.ˏॱ(jSONObject.getString("head"));
            o_cuk.ॱˊ(jSONObject.getString("body"));
            if (jSONObject.has("linkUrl")) {
                o_cuk.ͺ(jSONObject.getString("linkUrl"));
            }
        }

        private static void ˋ(cuk o_cuk, JSONObject jSONObject) throws JSONException {
            o_cuk.ʻॱ("5");
            o_cuk.ॱॱ(jSONObject.getString("name"));
            o_cuk.ˎ(jSONObject.getString("id"));
            o_cuk.ॱˎ(jSONObject.getString("catalog"));
            if (jSONObject.has("stars")) {
                o_cuk.ˋॱ(jSONObject.getString("stars"));
            }
            if (jSONObject.has("dialog")) {
                o_cuk.ᐝ(jSONObject.getBoolean("dialog") + "");
            }
        }

        private static void ˏ(cuk o_cuk, JSONObject jSONObject) throws JSONException {
            o_cuk.ʻॱ("3");
            o_cuk.ͺ(jSONObject.getString("linkUrl"));
            o_cuk.ˊॱ(jSONObject.getString("userInfo"));
        }

        private static void ˊ(cuk o_cuk, JSONObject jSONObject) throws JSONException {
            o_cuk.ʻॱ(HwAccountConstants.TYPE_SINA);
            o_cuk.ʼॱ(jSONObject.getString("target"));
            o_cuk.ॱˋ(jSONObject.getString("type"));
            o_cuk.ᐝॱ(o_cuk.ʻॱ() + "_" + o_cuk.ॱᐝ());
            o_cuk.ͺ(jSONObject.optString("url"));
            o_cuk.ʽॱ(jSONObject.getString("detailId"));
        }

        private static void ˎ(cuk o_cuk, JSONObject jSONObject) throws JSONException {
            o_cuk.ʻॱ(HwAccountConstants.TYPE_TENCENT);
            o_cuk.ʼॱ(jSONObject.getString("target"));
            o_cuk.ॱˋ(jSONObject.getString("type"));
            o_cuk.ͺ(jSONObject.getString("url"));
        }

        private static void ʻ(cuk o_cuk, JSONObject jSONObject) throws JSONException {
            o_cuk.ʻॱ("12");
            o_cuk.ͺ(jSONObject.getString("url"));
            o_cuk.ʾ(jSONObject.getString("accountId"));
        }

        private static void ᐝ(cuk o_cuk, JSONObject jSONObject) throws JSONException {
            o_cuk.ʾ(jSONObject.getString("accountId"));
            o_cuk.ʻॱ("8");
            o_cuk.ˎ(jSONObject.getString("appId"));
            o_cuk.ˈ(jSONObject.getString("commentId"));
        }

        private static void ʼ(cuk o_cuk, JSONObject jSONObject) throws JSONException {
            o_cuk.ʻॱ("11");
            o_cuk.ˏ(jSONObject.getString("serviceType"));
            if (jSONObject.getString("serviceType").equals("activity")) {
                o_cuk.ˉ(jSONObject.getString("activityName"));
                o_cuk.ˊˊ(jSONObject.getString("activityParams"));
                return;
            }
            Logger.e("PushNotificationTask", "Unknown service type.");
        }
    }

    protected /* synthetic */ Object doInBackground(Object[] objArr) {
        return ˋ((String[]) objArr);
    }

    protected /* synthetic */ void onPostExecute(Object obj) {
        ˏ((cuk) obj);
    }

    public eeo(Context context) {
        this.ˎ = context;
    }

    private static void ॱ(cuk o_cuk, JSONObject jSONObject) throws JSONException {
        o_cuk.ʻॱ("16");
        if (jSONObject.has("taskinfo")) {
            o_cuk.ॱˊ(jSONObject.getString("taskinfo"));
        }
    }

    protected cuk ˋ(String... strArr) {
        Logger.ˎ("PushNotificationTask", "doInBackground()");
        try {
            this.ॱ = new JSONObject(strArr[0]);
            cuk ˎ = ˎ(ˎ());
            if ("5".equals(ˎ.ॱˎ())) {
                cvt o_eaj = new eaj(ˎ.ˎ(), ˎ.ᐝ());
                if (this.ˎ instanceof Activity) {
                    o_eaj.setServiceType_(dgm.ˎ((Activity) this.ˎ));
                }
                GetDetailByIdResBean getDetailByIdResBean = (GetDetailByIdResBean) cfw.ॱ(o_eaj);
                if (!(getDetailByIdResBean == null || CollectCheck.isEmpty(getDetailByIdResBean.ˏ()))) {
                    GetDetailByIdResBean$DetailInfoBean getDetailByIdResBean$DetailInfoBean = (GetDetailByIdResBean$DetailInfoBean) getDetailByIdResBean.ˏ().get(0);
                    ˎ.ˋ(getDetailByIdResBean$DetailInfoBean.ʻ());
                    ˎ.ͺ(getDetailByIdResBean$DetailInfoBean.ॱॱ());
                    ˎ.ˋˊ(getDetailByIdResBean$DetailInfoBean.ˋॱ());
                    ˎ.ॱᐝ(getDetailByIdResBean$DetailInfoBean.ᐝ());
                    ˎ.ʻ(getDetailByIdResBean$DetailInfoBean.ʽ());
                    ˎ.ʽॱ(getDetailByIdResBean$DetailInfoBean.ͺ());
                    ˎ.ˎ(getDetailByIdResBean$DetailInfoBean.ˎ());
                    ˎ.ॱ(getDetailByIdResBean$DetailInfoBean.ʻॱ());
                }
            }
            final String ॱˋ = ˎ.ॱˋ();
            final String ˈ = ˎ.ˈ();
            if (!dof.ʽ(ˈ)) {
                dmq.ˏ.ॱ(new dmi(this) {
                    final /* synthetic */ eeo ˎ;

                    public void run() {
                        if (this.ˎ.ˊ != null) {
                            this.ˎ.ˊ.recycle();
                            this.ˎ.ˊ = null;
                        }
                        this.ˎ.ˊ = eqx.ˋ(this.ˎ.ˎ, ˈ);
                    }
                });
            }
            if (!dof.ʽ(ॱˋ)) {
                dmq.ˏ.ॱ(new dmi(this) {
                    final /* synthetic */ eeo ˋ;

                    public void run() {
                        this.ˋ.ˏ(ॱˋ);
                    }
                });
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    Logger.e("PushNotificationTask", "doInBackground(String... params) " + e.toString());
                }
            }
            return ˎ;
        } catch (OutOfMemoryError e2) {
            Logger.e("PushNotificationTask", "doInBackground(String... params) ");
            return null;
        } catch (Exception e3) {
            Logger.e("PushNotificationTask", "doInBackground(String... params) " + e3.toString());
            return null;
        }
    }

    private void ˏ(String str) {
        if (this.ˋ != null) {
            this.ˋ.recycle();
            this.ˋ = null;
        }
        this.ˋ = eqx.ˋ(this.ˎ, str);
    }

    private int ˎ() throws JSONException {
        String string = this.ॱ.getString("cmd");
        if (HianalyticsData.EXCEPTION_MESSAGE.equals(string)) {
            return ॱ().intValue();
        }
        if ("app".equals(string)) {
            return ˏ().intValue();
        }
        if ("web".equals(string)) {
            return ˊ().intValue();
        }
        if ("hispace".equals(string)) {
            return ˋ().intValue();
        }
        if ("feedBack".equals(string)) {
            return ʻ().intValue();
        }
        if ("webview".equals(string)) {
            return ᐝ().intValue();
        }
        if ("bindPhone".equals(string)) {
            return ʽ().intValue();
        }
        if ("commentReply".equals(string)) {
            return ʼ().intValue();
        }
        if ("selfDef".equals(string)) {
            return ॱॱ().intValue();
        }
        return Integer.MIN_VALUE;
    }

    private Integer ॱ() throws JSONException {
        return Integer.valueOf(this.ॱ.getJSONObject("param").getString("head").hashCode());
    }

    private Integer ˏ() throws JSONException {
        return Integer.valueOf(this.ॱ.getJSONObject("param").getString("id").hashCode());
    }

    private Integer ˊ() throws JSONException {
        return Integer.valueOf(this.ॱ.getJSONObject("param").getString("linkUrl").hashCode());
    }

    private Integer ˋ() throws JSONException {
        return Integer.valueOf(this.ॱ.getJSONObject("param").getString("target").hashCode());
    }

    private Integer ᐝ() throws JSONException {
        return Integer.valueOf(this.ॱ.getJSONObject("param").getString("url").hashCode());
    }

    private Integer ʽ() throws JSONException {
        return ᐝ();
    }

    private Integer ʻ() throws JSONException {
        return Integer.valueOf(this.ॱ.getString("content").hashCode());
    }

    private Integer ʼ() throws JSONException {
        return Integer.valueOf(this.ॱ.getString("content").hashCode());
    }

    private Integer ॱॱ() throws JSONException {
        String string = this.ॱ.getString("title");
        String string2 = this.ॱ.getString("content");
        return Integer.valueOf((string + string2 + this.ॱ.getJSONObject("param").getString("serviceType")).hashCode());
    }

    protected void ˏ(cuk o_cuk) {
        if (o_cuk != null) {
            Logger.ˎ("PushNotificationTask", "PushNotificationTask onPostExecute msgBean=" + o_cuk);
            boolean ˏ = euf.ˎ().ˏ();
            Logger.ˎ("PushNotificationTask", "PushNotificationTask onPostExecute pushsmsFlag=" + ˏ);
            if (!"addGameReserveInfo".equals(o_cuk.ʻॱ()) && !"addWishInfo".equals(o_cuk.ʻॱ()) && !ˏ) {
                return;
            }
            if ("addGameReserveInfo".equals(o_cuk.ʻॱ())) {
                ˊ(o_cuk);
                return;
            } else if ("addWishInfo".equals(o_cuk.ʻॱ())) {
                ॱ(o_cuk);
                return;
            } else {
                Serializable o_dkn = new dkn("" + o_cuk.ʿ(), o_cuk.ʻॱ(), o_cuk.ʼ(), o_cuk.ᐝ());
                o_dkn.onEventNotifyShow(this.ˎ);
                if (Logger.ˎ()) {
                    Logger.ˏ("PushNotificationTask", "versionCode = " + o_cuk.ˏ());
                }
                ˋ(o_cuk);
                Intent intent = new Intent("android.huawei.appmarket.pushdeal.dispatchnew");
                intent.setPackage(ContentManager.getInstant().getContext().getPackageName());
                Bundle bundle = new Bundle();
                bundle.putSerializable("anytic_args_key", o_dkn);
                bundle.putSerializable(PushDealReceiver.PUSH_MSG_BEAN, o_cuk);
                intent.putExtra(PushDealReceiver.PUSH_DISPATCH_BUNDLE_KEY, bundle);
                ˎ(o_cuk, intent);
                return;
            }
        }
        Logger.ˎ("PushNotificationTask", "msgBean is null，dont show notify");
    }

    private void ˋ(cuk o_cuk) {
        if ("commentReply".equals(o_cuk.ʻॱ())) {
            Intent intent = new Intent("com.huawei.appmarket.service.broadcast.CommentReplyAdded");
            intent.putExtra("ACTION_PARAM_COMMENT_REPLY_ADDED_TYPE_COMMENTID", o_cuk.ʼॱ());
            intent.putExtra("ACTION_PARAM_COMMENT_ADDED_TYPE_APPID", o_cuk.ˎ());
            ll ˏ = ll.ˏ(ContentManager.getInstant().getContext());
            ˏ.ˋ(intent);
            intent = new Intent("com.huawei.appmarket.service.broadcast.CommentAdded");
            intent.putExtra("ACTION_PARAM_COMMENT_ADDED_TYPE_APPID", o_cuk.ˎ());
            ˏ.ˋ(intent);
        }
    }

    private cuk ˎ(int i) throws JSONException {
        return b.ˏ(this.ॱ, i);
    }

    private void ˎ(cuk o_cuk, Intent intent) {
        String string;
        JSONException e;
        Object obj;
        int ˎ;
        Context ˋ;
        int ˎ2;
        dko o_dko;
        dkk o_dkk;
        Logger.ˎ("PushNotificationTask", "showNofitication()");
        String str = "";
        String str2 = "";
        try {
            string = this.ॱ.getString("title");
            try {
                str2 = this.ॱ.getString("content");
            } catch (JSONException e2) {
                e = e2;
                Logger.ˋ("PushNotificationTask", "showNofitication JSONException : " + e.toString());
                obj = null;
                ˎ = ˎ(o_cuk);
                if (ˎ == 0) {
                    ˋ = ContentManager.getInstant().getContext();
                    ˎ2 = erz.ˎ(ˋ, ˋ.getPackageName());
                    if (Logger.ˎ()) {
                        Logger.ˏ("PushNotificationTask", "TargerVersion: " + ˎ + ", LocalVersion: " + ˎ2);
                    }
                    if (ˎ2 < ˎ) {
                        intent = ˎ(ˋ, o_cuk.ʻॱ(), ˎ2, ˎ);
                        obj = 1;
                    }
                } else if (TextUtils.isEmpty(o_cuk.ॱˎ())) {
                    Logger.ˎ("PushNotificationTask", "msgBean.type is blank，not save，not show");
                    return;
                }
                o_dko = new dko();
                o_dko.ˋ(string);
                o_dko.ˊ(str2);
                o_dko.ˊ(intent);
                o_dko.ˏ(o_cuk.ʿ());
                o_dko.ˏ(this.ˋ);
                o_dko.ˊ(this.ˊ);
                o_dkk = new dkk(ContentManager.getInstant().getContext(), o_dko);
                o_dkk.ˋ();
                if (obj != null) {
                    o_dkk.ˎ();
                } else {
                    o_dkk.ˋ();
                }
            }
        } catch (JSONException e3) {
            JSONException jSONException = e3;
            string = str;
            e = jSONException;
            Logger.ˋ("PushNotificationTask", "showNofitication JSONException : " + e.toString());
            obj = null;
            ˎ = ˎ(o_cuk);
            if (ˎ == 0) {
                ˋ = ContentManager.getInstant().getContext();
                ˎ2 = erz.ˎ(ˋ, ˋ.getPackageName());
                if (Logger.ˎ()) {
                    Logger.ˏ("PushNotificationTask", "TargerVersion: " + ˎ + ", LocalVersion: " + ˎ2);
                }
                if (ˎ2 < ˎ) {
                    intent = ˎ(ˋ, o_cuk.ʻॱ(), ˎ2, ˎ);
                    obj = 1;
                }
            } else if (TextUtils.isEmpty(o_cuk.ॱˎ())) {
                Logger.ˎ("PushNotificationTask", "msgBean.type is blank，not save，not show");
                return;
            }
            o_dko = new dko();
            o_dko.ˋ(string);
            o_dko.ˊ(str2);
            o_dko.ˊ(intent);
            o_dko.ˏ(o_cuk.ʿ());
            o_dko.ˏ(this.ˋ);
            o_dko.ˊ(this.ˊ);
            o_dkk = new dkk(ContentManager.getInstant().getContext(), o_dko);
            o_dkk.ˋ();
            if (obj != null) {
                o_dkk.ˋ();
            } else {
                o_dkk.ˎ();
            }
        }
        obj = null;
        ˎ = ˎ(o_cuk);
        if (ˎ == 0) {
            ˋ = ContentManager.getInstant().getContext();
            ˎ2 = erz.ˎ(ˋ, ˋ.getPackageName());
            if (Logger.ˎ()) {
                Logger.ˏ("PushNotificationTask", "TargerVersion: " + ˎ + ", LocalVersion: " + ˎ2);
            }
            if (ˎ2 < ˎ) {
                intent = ˎ(ˋ, o_cuk.ʻॱ(), ˎ2, ˎ);
                obj = 1;
            }
        } else if (TextUtils.isEmpty(o_cuk.ॱˎ())) {
            Logger.ˎ("PushNotificationTask", "msgBean.type is blank，not save，not show");
            return;
        }
        o_dko = new dko();
        o_dko.ˋ(string);
        o_dko.ˊ(str2);
        o_dko.ˊ(intent);
        o_dko.ˏ(o_cuk.ʿ());
        o_dko.ˏ(this.ˋ);
        o_dko.ˊ(this.ˊ);
        o_dkk = new dkk(ContentManager.getInstant().getContext(), o_dko);
        o_dkk.ˋ();
        if (obj != null) {
            o_dkk.ˎ();
        } else {
            o_dkk.ˋ();
        }
    }

    private int ˎ(cuk o_cuk) {
        try {
            return Integer.parseInt(o_cuk.ˏ());
        } catch (NumberFormatException e) {
            Logger.ˋ("PushNotificationTask", "NumberFormatException : " + e.toString());
            return 0;
        }
    }

    private Intent ˎ(Context context, String str, int i, int i2) {
        cjo thirdAppDownloadActivityProtocol = new ThirdAppDownloadActivityProtocol();
        Request request = new Request();
        request.ˊ(i);
        request.ˋ(i2);
        request.ˎ(str);
        thirdAppDownloadActivityProtocol.ˊ(request);
        cjm o_cjm = new cjm("show.update.activity", thirdAppDownloadActivityProtocol);
        o_cjm.ॱ().setFlags(268435456);
        return o_cjm.ॱ(context);
    }

    private void ˊ(cuk o_cuk) {
        Object ͺ = o_cuk.ͺ();
        if (!TextUtils.isEmpty(ͺ)) {
            try {
                JSONObject jSONObject = new JSONObject(ͺ);
                ReserveResponse reserveResponse = new ReserveResponse();
                reserveResponse.fromJson(jSONObject);
                efb.ॱ().ˎ(reserveResponse, reserveResponse.ˊ());
            } catch (JSONException e) {
                Logger.ˎ("PushNotificationTask", "msgBody json error JSONException");
            } catch (IllegalArgumentException e2) {
                Logger.ˎ("PushNotificationTask", "msgBody json error IllegalArgumentException");
            } catch (IllegalAccessException e3) {
                Logger.ˎ("PushNotificationTask", "msgBody json error IllegalArgumentException");
            } catch (InstantiationException e4) {
                Logger.ˎ("PushNotificationTask", "msgBody json error IllegalArgumentException");
            } catch (ClassNotFoundException e5) {
                Logger.ˎ("PushNotificationTask", "msgBody json error IllegalArgumentException");
            }
        }
    }

    private void ॱ(cuk o_cuk) {
        eny.ˊ().ˋ(o_cuk.ͺ());
    }
}
